﻿/*****************************************************************************
* Project:
* All project
* Copyright(C) 2020-2021 Shenju Co.Ltd, All rights reserved.
* Description:
* All code is genrated by yangyang
* Author:
* yangyang
****************************************************************************/

#include "stdafx.h"
#include "AVI_Player.h"

#include "draw.h"
#include "def.h"

#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include <malloc.h>
#include <assert.h>

extern CWnd* pScreenWnd;
DWORD ScreenBmp[lcddev_height][lcddev_width];

DWORD RGB_from_565(unsigned short d)
{
	BYTE r,g,b;
	b = (d << 3) & 0xf8;
	g = (d >> 3) & 0xfc;
	r = (d >> 8) & 0xf8;
	return RGB(r,g,b);
}

void draw_rgb(unsigned short * buf, int start_line)
{
	printf("start_line=%d\r\n", start_line);

	ASSERT(start_line <= lcddev_height-40);

	for(int i=0; i<DRAW_LINES; i++)
	{
		for(int j=0; j<lcddev_width; j++)
		{
			ScreenBmp[i+start_line][j] = RGB_from_565(buf[i*lcddev_width+j]);
		}
	}

	pScreenWnd->SendMessage(WM_USER_DRAW, (WPARAM)ScreenBmp, sizeof(ScreenBmp));
}

